#include "exti.h"
void extiInit(void)
{
	GPIO_InitTypeDef GPIO_InitStruct;
	EXTI_InitTypeDef EXTI_InitStruct;
	NVIC_InitTypeDef NVIC_InitStruct;
	        
	//开时钟
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
	
	//配置GPIO引脚为输入模式
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
	GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;
	GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
	GPIO_Init(GPIOE, &GPIO_InitStruct);
	
	//配置外部中断线路
	SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE, EXTI_PinSource4);	//指定中断源
	SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE, EXTI_PinSource5);	//指定中断源
	
	//配置中断触发方式
	EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;	//中断模式
	EXTI_InitStruct.EXTI_Line = EXTI_Line4|EXTI_Line5;			//配置外部线
	EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling; //双边沿触发
	EXTI_InitStruct.EXTI_LineCmd = ENABLE;				//外部线使能
	EXTI_Init(&EXTI_InitStruct);

	//配置NVIC中断优先级
	NVIC_InitStruct.NVIC_IRQChannel = EXTI4_IRQn|EXTI9_5_IRQn;//中断通道
	NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;//抢占优先级
	NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;//响应优先级
	NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;//使能
	NVIC_Init(&NVIC_InitStruct);

	//后续还需要在it文件中配置中断服务函数
	
}

